#include <iostream>
#define LL long long
using namespace std;

const int kMaxN = 16;

int step[1 << kMaxN];

int main() {
  freopen("blink.in", "r", stdin);
  freopen("blink.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, state = 0;
  LL b;

  cin >> n >> b;
  for (int i = 0; i < n; i++) {
    int l;

    cin >> l;
    state = state * 2 + l;
  }
  step[state] = 1;
  b++;
  for (int t = 2; t <= b; t++) {
    int next = (((state << (n - 1)) + (state >> 1)) & ((1 << n) - 1)) ^ state;

    if (step[next] != 0) {
      b = t + (b - t) % (t - step[next]);
    }
    step[next] = t;
    state = next;
  }
  for (int i = n - 1; i >= 0; i--) {
    cout << ((state >> i) & 1) << "\n";
  }
  return 0;
}